/*
 * {author: UTE,
 *   capacity: 321403,
 *   createtime: 2023-12-23 17:34:20,
 *   download_num: 0,
 *   dpi: 368*448,
 *   id: 114478,
 *   level: 1,
 *   material: 1,
 *   maxCapacity: 0,
 *   preview: https://update.ute-tech.com.cn/watch/all/all/preview/1703324049_8266.png,
 *   resource: https://update.ute-tech.com.cn/watch/all/all/resource/1705301559_4131.bin,
 *   shape: 1,
 *   title: D11767001,
 *   type: 1},
 */
class DialModel {
  String author = '';
  int capacity = 0;
  String createtime = '';
  int download_num = 0;
  String dpi = '';
  int id = 0;
  int level = 0;
  String material = '';
  int maxCapacity = 0;
  String preview = '';
  String resource = '';
  int shape = 0;
  String title = '';
  int type = 0;
  bool isSelect = false;
  String bleId = '';

  DialModel fromJson(Map<dynamic, dynamic> map) {
    author = map['author']??'';
    capacity = map['capacity']??0;
    createtime = map['createtime']??'';
    download_num = map['download_num']??0;
    dpi = map['dpi']??'';
    id = map['id']??0;
    level = map['level']??0;
    material = map['material']??'';
    maxCapacity = map['maxCapacity']??0;
    preview = map['preview']??'';
    resource = map['resource']??'';
    shape = map['shape']??0;
    title = map['title']??'';
    type = map['type']??0;
    bleId = map.containsKey('bleId')?'${map['bleId']}':'';
    isSelect = map.containsKey('isSelect')?map['isSelect']:false;
    return this;
  }

  String toJson() {
    return '{'
        '"author":"$author",'
        '"capacity":$capacity,'
        '"createtime":"$createtime",'
        '"download_num":$download_num,'
        '"dpi":"$dpi",'
        '"id":$id,'
        '"level":$level,'
        '"material":"$material",'
        '"maxCapacity":$maxCapacity,'
        '"preview":"$preview",'
        '"resource":"$resource",'
        '"shape":$shape,'
        '"title":"$title",'
        '"type":$type,'
        '"bleId":"$bleId",'
        '"isSelect":$isSelect'
        '}';
  }

  @override
  String toString() {
    return 'id:$id,title:$title,author:$author,capacity:$capacity,createtime:$createtime,preview:$preview,bleId:$bleId,isSelect:$isSelect';
  }

  @override
  int get hashCode {
    int code = title.hashCode;
    return code;
  }

  @override
  bool operator ==(Object other) {
    if (other is! DialModel) {
      return false;
    }
    final DialModel otherModel = other;
    return (title.isNotEmpty &&
        title.compareTo(otherModel.title ?? '') == 0);
  }

}